{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 800x600 with 4 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# fake data\n",
    "x = np.linspace(-5, 5, 100)\n",
    "\n",
    "# following are popular activation functions\n",
    "y_relu = tf.nn.relu(x)\n",
    "y_sigmoid = tf.nn.sigmoid(x)\n",
    "y_tanh = tf.nn.tanh(x)\n",
    "y_softplus = tf.nn.softplus(x)\n",
    "# y_softmax = tf.nn.softmax(x)  softmax is a special kind of activation function, it is about probability\n",
    "\n",
    "# plt to visualize these activation function\n",
    "plt.figure(1, figsize=(8, 6))\n",
    "plt.subplot(221)\n",
    "plt.plot(x, y_relu, c='red', label='relu')\n",
    "plt.ylim((-1, 5))\n",
    "plt.legend(loc='best')\n",
    "\n",
    "plt.subplot(222)\n",
    "plt.plot(x, y_sigmoid, c='red', label='sigmoid')\n",
    "plt.ylim((-0.2, 1.2))\n",
    "plt.legend(loc='best')\n",
    "\n",
    "plt.subplot(223)\n",
    "plt.plot(x, y_tanh, c='red', label='tanh')\n",
    "plt.ylim((-1.2, 1.2))\n",
    "plt.legend(loc='best')\n",
    "\n",
    "plt.subplot(224)\n",
    "plt.plot(x, y_softplus, c='red', label='softplus')\n",
    "plt.ylim((-0.2, 6))\n",
    "plt.legend(loc='best')\n",
    "\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
